package com.st.service.impl;

import com.st.dao.TranscactionDao;
import com.st.service.TranscactionService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import javax.annotation.Resource;

@Service
public class TranscactionServiceImpl implements TranscactionService {
    @Resource
    private TranscactionDao transcactionDao;

    @Override
    @Transactional(value = "transactionManagerBase",
            isolation = Isolation.REPEATABLE_READ,
            propagation = Propagation.REQUIRED,
            rollbackFor = Exception.class)
    public int zz(int rmb) throws Exception {
        int suc = transcactionDao.zz(rmb);
        if (suc != 0) {
            throw new Exception("回滚异常测试");
        }
        return suc;
    }

}
